from PyQt4 import QtGui
from PyQt4.QtCore import Qt

class TartImage(QtGui.QWidget):
        def __init__(self, *args, **kw):
		QtGui.QWidget.__init__(self, *args, **kw)
		self.setGeometry(0, 0, 225, 310)

		bg = QtGui.QLabel(self) 
		bg.setGeometry(0, 0, 225, 310)
		path = "resources/tart_image_back.png"
		bg.setPixmap(QtGui.QPixmap(path))

		image = QtGui.QLabel(self) 
		image.setGeometry(11, 11, 203, 287)
		self.image = image

		fg = QtGui.QLabel(self) 
		fg.setGeometry(0, 0, 225, 310)
		path = "resources/tart_image_top.png"
		fg.setPixmap(QtGui.QPixmap(path))

	def set_image(self, path):
		pm = QtGui.QPixmap(path)
		pms = pm.scaled(203, 287, Qt.KeepAspectRatio)
		self.image.setPixmap(pms)
		self.image.setAlignment(Qt.AlignVCenter|Qt.AlignHCenter)


if __name__ == "__main__":
	import sys
	from glob import glob

	app = QtGui.QApplication(sys.argv)

	top = QtGui.QLabel()
	top.setGeometry(0, 0, 1024, 768)
	path = "resources/wood.jpg"
	top.setPixmap(QtGui.QPixmap(path))

	index = 0
	ll = glob("resources/characters/Bunny Girl/*.jpg")

	screen = TartImage(top)
	screen.move(50,50)
	screen.set_image(ll[index])

	def next_cb():
		global index

		index += 1
		if index >= len(ll):
			index = 0
		screen.set_image(ll[index])

	next = QtGui.QPushButton(top)
	next.setText("Next")
	next.clicked.connect(next_cb)
	next.move(50,400)

	top.show()
	sys.exit(app.exec_())


